<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>比较数值在数组的区间位置</title>
    <link rel="stylesheet" type="text/css" href="../../style/public.css">
</head>
<body>
    <div id="section">
        <p>比较数值在数组的区间位置</p>
    </div>
	
</body>
    <script>
    /***比较数值在数组的区间位置************************************/
    var comArrIdex = function(arr, num){
        var arrLen = arr.length;
        var arrLenMax = arrLen -1;
        for (var ai = 0; ai < arrLen; ai++) {
            if (ai != arrLenMax) {
                var comMin = arr[ai], comMax = arr[ai+1];
                if (num >= comMin && num < comMax) {
                    return arr[ai];
                };
            }else{
                return arr[ai];
            }
        };
    } 
    </script>
</html>